﻿using MyHospital.BLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace MyHospital.web.MyHospital
{
    public partial class ChangePwd : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void btnChangePwd_Click(object sender, EventArgs e)
        {
            User user = new User();
            if (Session["PatientID"] != null)
            {
                if (user.IsPatientPwdTrue((int)Session["PatientID"], txtOldPwd.Text) == true)
                {
                    user.NewPatientPwd((int)Session["PatientID"], txtPwd.Text);
                    lblMsg.Text = "修改成功！";
                    Response.Write("<script>alert('重新登陆！');window.location.href='Login.aspx';</script>");
                }
                else lblMsg.Text = "密码错误！";
            }
            else if (Session["AdminID"] != null)
            {
                if(user.IsAdminPwdTrue((int)Session["AdminID"], txtOldPwd.Text) == true)
                {
                    user.NewAdminPwd((int)Session["AdminID"], txtPwd.Text);
                    lblMsg.Text = "修改成功！";
                    Response.Write("<script>alert('重新登陆！');window.location.href='Login.aspx';</script>");
                }
                else lblMsg.Text = "密码错误！";
            }
        }
    }
}